USE [FB91DWCRWork2]
GO

/****** Object:  Table [dbo].[FBSalesOrganizationStructure]    Script Date: 4/25/13 1:47:18 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[FBSalesOrganizationStructure]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[FBSalesOrganizationStructure](
	[AddressNumber] [int] NOT NULL,
	[OperationLevel01] [int] NOT NULL,
	[OperationLevelDesc01] [char](40) NOT NULL,
	[OperationLevel02] [int] NOT NULL,
	[OperationLevelDesc02] [char](40) NOT NULL,
	[OperationLevel03] [int] NOT NULL,
	[OperationLevelDesc03] [char](40) NOT NULL,
	[OperationLevel04] [int] NOT NULL,
	[OperationLevelDesc04] [char](40) NOT NULL,
	[OperationLevel05] [int] NOT NULL,
	[OperationLevelDesc05] [char](40) NOT NULL,
	[OperationLevel06] [int] NOT NULL,
	[OperationLevelDesc06] [char](40) NOT NULL,
	[OperationLevel07] [int] NOT NULL,
	[OperationLevelDesc07] [char](40) NOT NULL,
	[OperationLevel08] [int] NOT NULL,
	[OperationLevelDesc08] [char](40) NOT NULL,
	[OperationLevel09] [int] NOT NULL,
	[OperationLevelDesc09] [char](40) NOT NULL,
	[OperationLevel10] [int] NOT NULL,
	[OperationLevelDesc10] [char](40) NOT NULL,
	[SalesLevel01] [int] NOT NULL,
	[SalesLevelDesc01] [char](40) NOT NULL,
	[SalesLevel02] [int] NOT NULL,
	[SalesLevelDesc02] [char](40) NOT NULL,
	[SalesLevel03] [int] NOT NULL,
	[SalesLevelDesc03] [char](40) NOT NULL,
	[SalesLevel04] [int] NOT NULL,
	[SalesLevelDesc04] [char](40) NOT NULL,
	[SalesLevel05] [int] NOT NULL,
	[SalesLevelDesc05] [char](40) NOT NULL,
	[SalesLevel06] [int] NOT NULL,
	[SalesLevelDesc06] [char](40) NOT NULL,
	[SalesLevel07] [int] NOT NULL,
	[SalesLevelDesc07] [char](40) NOT NULL,
	[SalesLevel08] [int] NOT NULL,
	[SalesLevelDesc08] [char](40) NOT NULL,
	[SalesLevel09] [int] NOT NULL,
	[SalesLevelDesc09] [char](40) NOT NULL,
	[SalesLevel10] [int] NOT NULL,
	[SalesLevelDesc10] [char](40) NOT NULL,
	[NAM01] [int] NOT NULL,
	[NAMDesc01] [char](40) NOT NULL,
	[NAM02] [int] NOT NULL,
	[NAMDesc02] [char](40) NOT NULL,
	[NAM03] [int] NOT NULL,
	[NAMDesc03] [char](40) NOT NULL,
	[NAM04] [int] NOT NULL,
	[NAMDesc04] [char](40) NOT NULL,
	[NAM05] [int] NOT NULL,
	[NAMDesc05] [char](40) NOT NULL,
	[NAM06] [int] NOT NULL,
	[NAMDesc06] [char](40) NOT NULL,
	[NAM07] [int] NOT NULL,
	[NAMDesc07] [char](40) NOT NULL,
	[NAM08] [int] NOT NULL,
	[NAMDesc08] [char](40) NOT NULL,
	[NAM09] [int] NOT NULL,
	[NAMDesc09] [char](40) NOT NULL,
	[NAM10] [int] NOT NULL,
	[NAMDesc10] [char](40) NOT NULL,
	[UserID] [char](10) NOT NULL,
	[ProgramID] [char](10) NOT NULL,
	[WorkStationID] [char](10) NOT NULL,
	[DateUpdated] [int] NOT NULL,
	[TimeofDay] [decimal](6, 0) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[AddressNumber] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO

SET ANSI_PADDING OFF
GO

ALTER AUTHORIZATION ON [dbo].[FBSalesOrganizationStructure] TO  SCHEMA OWNER 
GO

/****** Object:  View [dbo].[FBSalesOrgStructure]    Script Date: 4/25/13 1:47:18 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[FBSalesOrgStructure]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[FBSalesOrgStructure]
AS
SELECT     dbo.FBSalesOrganizationStructure.*
FROM         dbo.FBSalesOrganizationStructure
' 
GO

ALTER AUTHORIZATION ON [dbo].[FBSalesOrgStructure] TO  SCHEMA OWNER 
GO

IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPane1' , N'SCHEMA',N'dbo', N'VIEW',N'FBSalesOrgStructure', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "FBSalesOrganizationStructure"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 121
               Right = 227
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'FBSalesOrgStructure'
GO

IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPaneCount' , N'SCHEMA',N'dbo', N'VIEW',N'FBSalesOrgStructure', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'FBSalesOrgStructure'
GO


